<template>
  <div class="page">
    <!-- 搜索区域 开始 -->
    <div class="el_card_box">
      <el-form :inline="true" size="small" :model="formInline" class="search_form">
        <el-form-item label="预约时间：">
          <el-date-picker v-model="orderTime" type="daterange" unlink-panels :picker-options="pickerOptions" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="首次收款时间：">
          <el-date-picker v-model="orderTime2" type="daterange" unlink-panels :picker-options="pickerOptions" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="预约医院：">
          <el-select v-model="formInline.city1">
            <el-option label="深圳" value="1"></el-option>
            <el-option label="湖南" value="2"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="城市：">
          <el-select v-model="formInline.city">
            <el-option label="深圳" value="1"></el-option>
            <el-option label="湖南" value="2"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="报名费处理：">
          <el-select v-model="formInline.city2">
            <el-option label="深圳" value="1"></el-option>
            <el-option label="湖南" value="2"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="收款情况：">
          <el-select v-model="formInline.sex">
            <el-option label="男" value="1"></el-option>
            <el-option label="女" value="2"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="成交项目：">
          <el-select v-model="formInline.city3">
            <el-option label="深圳" value="1"></el-option>
            <el-option label="湖南" value="2"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="负责人：">
          <el-select v-model="formInline.city4">
            <el-option label="深圳" value="1"></el-option>
            <el-option label="湖南" value="2"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="关键词：">
          <el-input v-model="formInline.channelName" placeholder="请输入客户姓名/电话"></el-input>
        </el-form-item>
      </el-form>
      <div class="search_btn_box">
        <el-button type="primary" size="small" @click="getList">筛选</el-button>
        <el-button type="default" size="small" @click="rest">清空筛选</el-button>
      </div>
    </div>
    <!-- 搜索区域 end -->

    <!-- 表格 开始 -->
    <div class="table_box">
      <!-- 操作区域 开始 -->
      <div class="action_box">
        <el-button type="primary" size="small" @click="openDialog('bookDialog')">收款变动</el-button>
        <el-button type="primary" size="small" @click="openDialog('bookDialog')">错误金额修正</el-button>
        <el-button type="default" size="small">导出筛选结果</el-button>
      </div>
      <!-- 操作区域 end -->

      <el-table ref="elTable" class="el_table" size="small" :data="tableData">
        <el-table-column prop="channelName" label="客户信息" width="160px">
          <template slot-scope="{row}">
            <tab-user :user="row"></tab-user>
          </template>
        </el-table-column>
        <el-table-column prop="settleRegisterCnt" label="预约医院" show-overflow-tooltip />
        <el-table-column prop="settleRegisterCnt" label="预约时间" show-overflow-tooltip />
        <el-table-column prop="downloadCnt" label="成交项目">
          <template>
            <div class="tag_list">
              <div class="tag">种植牙</div>
              <div class="tag">贴面</div>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="uv" label="报名费处理">
          <template>99元</template>
        </el-table-column>
        <el-table-column prop="settleRegisterRatio" label="收款情况" show-overflow-tooltip />
        <el-table-column prop="settleRegisterRatio" label="总成交额" show-overflow-tooltip />
        <el-table-column prop="settleRegisterRatio" label="总收款金额" show-overflow-tooltip />
        <el-table-column prop="settleRegisterRatio" label="首次收款时间" show-overflow-tooltip />
        <el-table-column prop="cost" label="负责人" show-overflow-tooltip />
        <el-table-column prop="address" label="操作" width="200px" align="center">
          <template slot-scope="{row}">
            <el-link type="primary" class="el_link" :underline="false" :id="row.id">收款明细</el-link>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination_list">
        <el-pagination background layout="sizes, total,prev, pager, next, jumper" :total="pageTotal" :page-size="pageSize" :page-sizes="pageSizes" :current-page.sync="pageNumber" @current-change="getList" @size-change="changePageSize" />
      </div>
    </div>
    <!-- 表格 end -->
  </div>
</template>

<script>
import {
  GETCHANNELLIST,
  CHANNELEXPORTURL,
  GETCHANNELURL,
} from "@/http/interface";
import { showToast, showModal, deepClone } from "@/common/util";
import { exportExcel } from "@/common/common";
import GlsxDialog from "@/components/Dialog/index";
import GlsxTable from "@/components/glsx-table/index";
import CustomerDetail from "../customer/detail";
import moment from "moment";
import TabUser from "@/components/user";
export default {
  name: "BookPage",
  props: {
    status: {
      type: [String, Number],
      default: "",
    },
  },
  components: {
    GlsxDialog,
    GlsxTable,
    CustomerDetail,
    TabUser,
  },
  data() {
    return {
      formInline: {},
      tableData: [],
      pageTotal: 0,
      pageNumber: 1,
      pageSizes: [10, 20, 30, 40],
      pageSize: 10,
      eloading: false,
      orderTime: [],
      showDialog: false,
      loading: false,
      bookDialog: false,
      checkList: [],
      pickerOptions: {
        shortcuts: [
          {
            text: "前天",
            onClick(picker) {
              const end = moment().subtract(2, "days").format("YYYY-MM-DD");
              const start = moment().subtract(2, "days").format("YYYY-MM-DD");
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "昨天",
            onClick(picker) {
              const end = moment().subtract(1, "days").format("YYYY-MM-DD");
              const start = moment().subtract(1, "days").format("YYYY-MM-DD");
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "今天",
            onClick(picker) {
              const end = moment().subtract(0, "days").format("YYYY-MM-DD");
              const start = moment().subtract(0, "days").format("YYYY-MM-DD");
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "明天",
            onClick(picker) {
              const end = moment().add(1, "days").format("YYYY-MM-DD");
              const start = moment().add(1, "days").format("YYYY-MM-DD");
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "后天",
            onClick(picker) {
              const end = moment().add(2, "days").format("YYYY-MM-DD");
              const start = moment().add(2, "days").format("YYYY-MM-DD");
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
      cancelDialog: false,
      remark: "",
      dialogTitle: "新增预约",
      shopDialog: false,
      shopVisitDialog: false,
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    /** 重置 */
    rest() {
      this.formInline = {};
      this.orderTime = [];
      this.getList();
    },

    /** 每页展示 */
    changePageSize(e) {
      this.pageSize = e;
      this.getList();
    },

    /** 获取参数 */
    getParams() {
      let oParams = JSON.parse(JSON.stringify(this.formInline));
      let n = this.orderTime;

      if (n && n.length > 0) {
        oParams.sDate = n[0];
        oParams.eDate = n[1];
      }

      oParams.pageNumber = this.pageNumber;
      oParams.pageSize = this.pageSize;
      return oParams;
    },

    /** 获取列表 */
    getList() {
      let _this = this;
      let oParams = this.getParams();
      GETCHANNELLIST(oParams).then((res) => {
        let obj = res.data || {};
        _this.tableData = obj.list || [];
        _this.pageTotal = obj.totalElements;
      });
    },

    // 打开弹框
    openDialog(id, row) {
      this[id || "showDialog"] = true;
    },

    // 关闭弹框
    closeDialog(id) {
      this[id || "showDialog"] = false;
    },


  },
};
</script>

<style lang="scss" scoped>
@import "@/assets/style/customer/index.scss";
</style>
